
package at.fhj.ase.crypto.common.net;

/**
 * Interface for implementation classes that are responsible for handling incoming messages.<br>
 * This could be used e.g. at socket connections or similar where input- and outputstream are behind.
 * <p>
 * Note that only classes should implement that interface that <strong>really</strong> are responsible for handling receiving and incoming messages over the
 * network!<br>
 * It does not make any sense to make a class implementing it e.g. just for convenience and delegating methods.
 * 
 * @author sfe | www.fh-joanneum.at | Practical Aspects of Cryptography
 */
public interface MessageHandler {
  /**
   * Do some action with the arriving message over network, e.g. a socket connection, like parsing, starting a GUI, processing the message or sending some
   * response.
   * 
   * @param msg the message that has to be handled as a {@link String} representation
   */
  void handleMessage(final String msg);

  /**
   * Method called if an error occurs, e.g. if the a connection is closed or similar
   * 
   * @param errorMsg the error message that should describe the occures error
   */
  void handleError(final String errorMsg);
}
